//
//  DLLApiManager.m
//  YueYueSpecailCarDriver
//
//  Created by DL on 17/1/9.
//  Copyright © 2017年 黄旺鑫. All rights reserved.
//

#import "DLLApiManager.h"
#import <ConnectionBaseManager/ConnectionBaseManager.h>
#import <QXDriverConfiguration/QXDriverConfiguration.h>
#import <DriverLoginManager/DriverLoginManager-umbrella.h>
#import <QXYueYueModels/QXYueYueModels-umbrella.h>
#import "NotificationNameManager.h"

#define YueYueTaiDriver_Tocken   [QXYYUserDriverModel QXYY_unarchiveObject].token
#define TimeLimites 10

@implementation DLLApiManager

#pragma mark -单例对象
+ (DLLApiManager *)sharedManager {
    static DLLApiManager *_sharedManager = nil;
    static dispatch_once_t oncePredicate;
    
    dispatch_once(&oncePredicate, ^{
        _sharedManager = [[self alloc] init];
    });
    
    return _sharedManager;
}
#pragma mark -统一处理回调
+ (void)connectWithRequest:(NSURLRequest*)request success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    [ConnectionBaseManager connectWithRequest:request completionHandler:^(id  _Nullable parameter, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        
        
        if (!error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                
            });
            
            if ([parameter[@"errCode"] integerValue] == 10011 || [parameter[@"errCode"] integerValue] == 10010) { // 10011 登录失效, 10010 登录过期 , 10012 账号被封
                
                dispatch_async(dispatch_get_main_queue(), ^{
                    
                    [[NSNotificationCenter defaultCenter] postNotificationName:DriverLoginOutSucessNotification object:nil]; // 发送登录请求,进入登录页面
                    
                });
                return ;
            }else if ([parameter[@"errCode"] integerValue] == 10012) {
                
                
                dispatch_async(dispatch_get_main_queue(), ^{
                    
                    [[NSNotificationCenter defaultCenter] postNotificationName:DriverLoginOutSucessNotification object:nil]; // 发送登录请求,进入登录页面
                    
                    NSString *reasonStr = parameter[@"msg"];
                    [[NSNotificationCenter defaultCenter] postNotificationName:NotificationName_UserAccountIsSealed object:reasonStr]; // 弹框
                });
//                return;
            }
            
            success(parameter);
            
            
        }
        else{
            failure(error);
            
        }
    }];
}

#pragma mark - 司机上下班接口
/**
 获取司机上下班状态
 */
+ (void)getDriverWorkingStateWithParameters:(NSDictionary *)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager getRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/work/isWork.yueyue" , [QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
    
}

/**
 司机开始上班
 */
+ (void)driverStartWorkingWithParameters:(NSDictionary *)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager getRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/work/on.yueyue" , [QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

/**
 司机下班
 */
+ (void)driverGoOffWorkWithParameters:(NSDictionary *)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager getRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/work/off.yueyue" , [QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

#pragma mark - 出车首页

/**
 获取司机消息中心列表
 
 @param parameters 使用的参数
 @param success 获取成功
 @param failure 获取失败
 */
+ (void)getDriverInformationListOfCenterWithParameters:(NSDictionary *)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager getRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/message/list.yueyue" , [QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

/**
 获取司机是否有正在进行中的订单
 
 @param parameters 使用的参数
 @param success 获取成功
 @param failure 获取失败
 */
+ (void)getOrderStatusWithParameters:(NSDictionary *)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    // 方法名
    NSString *methodName;
    
    QXYYUserDriverModel *driverModel = [QXYYUserDriverModel QXYY_unarchiveObject];
    if (driverModel.type == 2) { // 专车
        
        methodName = @"/api/v1/driver/token/specialOrder/status.yueyue";
    }else if (driverModel.type == 4) { // 快车
        
        methodName = @"/api/v1/driver/token/ExpressOrder/status.yueyue";
    }else if (driverModel.type == 1) { // 出租车
        
        methodName = @"/api/v1/driver/token/order/status.yueyue";
    }else if (driverModel.type == 5) { // 货的
        
        methodName = @"/api/v1/driver/token/truck/order/status.yueyue";
    }else if (driverModel.type == 6) { // 骑手
        
        methodName = @"/api/v1/driver/token/rider/order/status.yueyue";
    }else if (driverModel.type == 7) { // 搬家
        
        methodName = @"/api/v1/driver/token/move/order/status.yueyue";
    }
    
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@%@",[QXDriverConfiguration apiBaseUrlString] , methodName] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

/**
 获取出车信息
 出车时间 , 订单数量 , 收入流水
 */
+ (void)getDrivingInfoWithParameters:(NSDictionary *)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/order/taxi/home.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites * 2;
    [self connectWithRequest:request success: success failure:failure];
}

#pragma mark - 司机首页消息接口
+ (void)getDriverHomePageMessageWithParameters:(NSDictionary *)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/message/homePageMessage.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

#pragma mark - 司机首页消息删除接口
+ (void)deleteHomePageMessageWithParameters:(NSDictionary *)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/message/del.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

#pragma mark - 司机预约单通知接口
+ (void)appointOrderWarningWithParameters:(NSDictionary *)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/order/getAppointmentToBeStart.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

#pragma mark - 司机订单接口
/// 获取订单列表接口
+ (void)getTheOrderListWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    

    // 方法名
    NSString *methodName;
    
    QXYYUserDriverModel *driverModel = [QXYYUserDriverModel QXYY_unarchiveObject];
    if (driverModel.type == 2) { // 专车
        
        methodName = @"/api/v1/driver/token/specialOrder/list.yueyue";
    }else if (driverModel.type == 4) { // 快车
        
        methodName = @"/api/v1/driver/token/ExpressOrder/list.yueyue";
    }else if (driverModel.type == 1) { // 出租车
        
        methodName = @"/api/v1/driver/token/order/list.yueyue";
    }else if (driverModel.type == 5) { // 货的
        
        methodName = @"/api/v1/driver/token/truck/order/list.yueyue";
    }else if (driverModel.type == 6) { // 骑手
        
        methodName = @"/api/v1/driver/token/rider/order/list.yueyue";
    }else if (driverModel.type == 7) { // 搬家
        
        methodName = @"/api/v1/driver/token/move/order/list.yueyue";
    }
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@%@",[QXDriverConfiguration apiBaseUrlString] , methodName] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}




/// 获取订单详情接口
+ (void)getTheOrderDetailsWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    // 方法名
    NSString *methodName;
    
    QXYYUserDriverModel *driverModel = [QXYYUserDriverModel QXYY_unarchiveObject];
    if (driverModel.type == 2) { // 专车
        
        methodName = @"/api/v1/driver/token/specialOrder/info.yueyue";
    }else if (driverModel.type == 4) { // 快车
        
        methodName = @"/api/v1/driver/token/ExpressOrder/info.yueyue";
    }else if (driverModel.type == 1) { // 出租车
        
        methodName = @"/api/v1/driver/token/order/info.yueyue";
    }else if (driverModel.type == 5) { // 货的
        
        methodName = @"/api/v1/driver/token/truck/order/info.yueyue";
    }else if (driverModel.type == 6) { // 骑手
        
        methodName = @"/api/v1/driver/token/rider/order/info.yueyue";
    }else if (driverModel.type == 7) { // 搬家
        
        methodName = @"/api/v1/driver/token/move/order/info.yueyue";
    }
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@%@",[QXDriverConfiguration apiBaseUrlString] , methodName] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

/// 去接乘客接口
+ (void)gotoPickUpPassengerWithParameters:(NSDictionary *)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    

    // 方法名
    NSString *methodName;
    
    QXYYUserDriverModel *driverModel = [QXYYUserDriverModel QXYY_unarchiveObject];
    if (driverModel.type == 2) { // 专车
        
        methodName = @"/api/v1/driver/token/specialOrder/pickUpPas.yueyue";
    }else if (driverModel.type == 4) { // 快车
        
        methodName = @"/api/v1/driver/token/ExpressOrder/pickUpPas.yueyue";
    }else if (driverModel.type == 1) { // 出租车
        
        methodName = @"/api/v1/driver/token/order/pickUpPas.yueyue";
    }else if (driverModel.type == 5) { // 货的
        
        methodName = @"/api/v1/driver/token/truck/order/pickUpPas.yueyue";
    }else if (driverModel.type == 6) { // 骑手
        
        methodName = @"/api/v1/driver/token/rider/order/pickUpPas.yueyue";
    }else if (driverModel.type == 7) { // 搬家
        
        methodName = @"/api/v1/driver/token/move/order/pickUpPas.yueyue";
    }
    
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@%@",[QXDriverConfiguration apiBaseUrlString] , methodName] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

/// 司机到达上车地点接口
+ (void)arrivingAtTheBoardingPointWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    //
    
    // 方法名
    NSString *methodName;
    
    QXYYUserDriverModel *driverModel = [QXYYUserDriverModel QXYY_unarchiveObject];
    if (driverModel.type == 2) { // 专车
        
        methodName = @"/api/v1/driver/token/specialOrder/depart.yueyue";
    }else if (driverModel.type == 4) { // 快车
        
        methodName = @"/api/v1/driver/token/ExpressOrder/depart.yueyue";
    }else if (driverModel.type == 1) { // 出租车
        
        methodName = @"/api/v1/driver/token/order/depart.yueyue";
    }else if (driverModel.type == 5) { // 货的
        
        methodName = @"/api/v1/driver/token/truck/order/depart.yueyue";
    }else if (driverModel.type == 6) { // 骑手
        
        methodName = @"/api/v1/driver/token/rider/order/depart.yueyue";
    }else if (driverModel.type == 7) { // 搬家
        
        methodName = @"/api/v1/driver/token/move/order/depart.yueyue";
    }
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@%@",[QXDriverConfiguration apiBaseUrlString] , methodName] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}
/// 司机接到乘客接口
+ (void)passengersAreOnCarWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    
    // 方法名
    NSString *methodName;
    
    QXYYUserDriverModel *driverModel = [QXYYUserDriverModel QXYY_unarchiveObject];
    if (driverModel.type == 2) { // 专车
        
        methodName = @"/api/v1/driver/token/specialOrder/geton.yueyue";
    }else if (driverModel.type == 4) { // 快车
        
        methodName = @"/api/v1/driver/token/ExpressOrder/geton.yueyue";
    }else if (driverModel.type == 1)  { // 出租车
        
        methodName = @"/api/v1/driver/token/order/geton.yueyue";
    }else if (driverModel.type == 5) { // 货的
        
        methodName = @"/api/v1/driver/token/truck/order/geton.yueyue";
    }else if (driverModel.type == 6) { // 骑手
        
        methodName = @"/api/v1/driver/token/rider/order/geton.yueyue";
    }else if (driverModel.type == 7) { // 搬家
        
        methodName = @"/api/v1/driver/token/move/order/geton.yueyue";
    }
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@%@",[QXDriverConfiguration apiBaseUrlString] , methodName] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}
/// 司机到达目的地接口
+ (void)driverArrivesAtTheDestinationWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    // 方法名
    NSString *methodName;
    
    QXYYUserDriverModel *driverModel = [QXYYUserDriverModel QXYY_unarchiveObject];
    if (driverModel.type == 2) { // 专车
        
        methodName = @"/api/v1/driver/token/specialOrder/arrive.yueyue";
    }else if (driverModel.type == 4) { // 快车
        
        methodName = @"/api/v1/driver/token/ExpressOrder/arrive.yueyue";
    }else if (driverModel.type == 1) { // 出租车
        
        methodName = @"/api/v1/driver/token/order/arrive.yueyue";
    }else if (driverModel.type == 5) { // 货的
        
        methodName = @"/api/v1/driver/token/truck/order/arrive.yueyue";
    }else if (driverModel.type == 6) { // 骑手
        
        methodName = @"/api/v1/driver/token/rider/order/arrive.yueyue";
    }else if (driverModel.type == 7) { // 搬家
        
        methodName = @"/api/v1/driver/token/move/order/arrive.yueyue";
    }
    
    
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@%@",[QXDriverConfiguration apiBaseUrlString] , methodName] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}
/// 司机投诉状态
+ (void)driverComplaintStateWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/order/isComplain.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}
/// 司机投诉列表接口
+ (void)driverComplaintListWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/tag/complain.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}
/// 司机投诉接口
+ (void)driverComplaintWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/complaint/add.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

/// 司机取消订单原因列表接口
+ (void)driverCancelOrderMsgListWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/tag/cancelMsg.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

/// 司机取消订单说明接口
+ (void)driverCancelOrderDescriptionWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/order/cancelDescription.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

/// 司机取消订单接口
+ (void)driverCancelOrderWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/order/cancel.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

/// 司机实时价格订单接口
+ (void)driverGetRealTimePriceWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    // 方法名
    NSString *methodName;
    
    QXYYUserDriverModel *driverModel = [QXYYUserDriverModel QXYY_unarchiveObject];
    if (driverModel.type == 2) { // 专车
        
        methodName = @"/api/v1/driver/token/specialOrder/getRealtimeFare.yueyue";
    }else if (driverModel.type == 4) { // 快车
        
        methodName = @"/api/v1/driver/token/ExpressOrder/getRealtimeFare.yueyue";
    }else if (driverModel.type == 5) { // 货的
        
        methodName = @"/api/v1/driver/token/truck/order/getRealTimeFare.yueyue";
    }else if (driverModel.type == 6) { // 骑手
        
        methodName = @"/api/v1/driver/token/rider/order/getRealTimeFare.yueyue";
    }else if (driverModel.type == 7) { // 搬家
        
        methodName = @"/api/v1/driver/token/move/order/getRealTimeFare.yueyue";
    }
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@%@",[QXDriverConfiguration apiBaseUrlString] , methodName] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

/// 司机确认费用接口
+ (void)confirmFareWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    // 方法名
    NSString *methodName;
    
    QXYYUserDriverModel *driverModel = [QXYYUserDriverModel QXYY_unarchiveObject];
    if (driverModel.type == 2) { // 专车
        
        methodName = @"/api/v1/driver/token/specialOrder/confirmFare.yueyue";
    }else if (driverModel.type == 4) { // 快车
        
        methodName = @"/api/v1/driver/token/ExpressOrder/confirmFare.yueyue";
    }else if (driverModel.type == 1) { // 出租车
        
        methodName = @"/api/v1/driver/token/order/updFare.yueyue";
    }else if (driverModel.type == 5) { // 货的
    
        methodName = @"/api/v1/driver/token/truck/order/confirmFare.yueyue";
    }else if (driverModel.type == 6) { // 骑手
        
        methodName = @"/api/v1/driver/token/rider/order/confirmFare.yueyue";
    }else if (driverModel.type == 7) { // 搬家
        
        methodName = @"/api/v1/driver/token/move/order/confirmFare.yueyue";
    }
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@%@",[QXDriverConfiguration apiBaseUrlString] , methodName] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}
/// 司机催款接口
+ (void)driverPressForMoneyWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/order/rushFare.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}
/// 司机订单费用详情接口
+ (void)driverOrderFareDetailsWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    

    // 方法名
    NSString *methodName;
    
    QXYYUserDriverModel *driverModel = [QXYYUserDriverModel QXYY_unarchiveObject];
    if (driverModel.type == 2) { // 专车
        
        methodName = @"/api/v1/driver/token/specialOrder/orderFare.yueyue";
    }else if (driverModel.type == 4) { // 快车
        
        methodName = @"/api/v1/driver/token/ExpressOrder/orderFare.yueyue";
    }else if (driverModel.type == 1) { // 出租车
        
        methodName = @"/api/v1/driver/token/order/fareItems.yueyue";
    }else if (driverModel.type == 5) { // 货的
        
        methodName = @"/api/v1/driver/token/truck/order/orderFare.yueyue";
    }else if (driverModel.type == 6) { // 骑手
        
        methodName = @"/api/v1/driver/token/rider/order/orderFare.yueyue";
    }else if (driverModel.type == 7) { // 搬家
        
        methodName = @"/api/v1/driver/token/move/order/orderFare.yueyue";
    }
    
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@%@",[QXDriverConfiguration apiBaseUrlString] , methodName] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

/// 司机订单超时等待费接口
+ (void)driverOrderWaitingFareDetailsWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/order/waitFare.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}



#pragma mark -司机抢单接口
+ (void)grabTheOrderWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    // 方法名
    NSString *methodName;
    
    QXYYUserDriverModel *driverModel = [QXYYUserDriverModel QXYY_unarchiveObject];
    if (driverModel.type == 2) { // 专车
        
        methodName = @"/api/v1/driver/token/specialOrder/grab.yueyue";
    }else if (driverModel.type == 4) { // 快车
        
        methodName = @"/api/v1/driver/token/ExpressOrder/grab.yueyue";
    }else if (driverModel.type == 1) { // 出租车
        
        methodName = @"/api/v1/driver/token/order/grab.yueyue";
    }else if (driverModel.type == 5) { // 货的
        
        methodName = @"/api/v1/driver/token/truck/order/grab.yueyue";
    }else if (driverModel.type == 6) { // 骑手
        
        methodName = @"/api/v1/driver/token/rider/order/grab.yueyue";
    }else if (driverModel.type == 7) { // 搬家
        
        methodName = @"/api/v1/driver/token/move/order/grab.yueyue";
    }
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@%@",[QXDriverConfiguration apiBaseUrlString] , methodName] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

#pragma mark - 听单模式设置
+ (void)listenModeSettingsWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/user/remind.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

#pragma mark - 获取配置文件
// 获取配置文件
//+ (void)getConfigureFileWithParameters:(NSDictionary *)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
//    
//    NSURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/common/driver/variable.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
//    [ConnectionBaseManager connectWithRequest:request completionHandler:^(id  _Nullable parameter, NSURLResponse * _Nullable response, NSError * _Nullable error) {
//        
//        if (parameter && [parameter isKindOfClass:[NSData class]]) {
//            NSPropertyListFormat format;
//            NSError *err;
//            id plist = [NSPropertyListSerialization propertyListWithData: parameter
//                                                                 options: NSPropertyListImmutable
//                                                                  format: &format
//                                                                   error: &err];
//            if (plist && [plist isKindOfClass:[NSDictionary class]]) {
//                success(plist);
//            }
//        } else {
//            failure(error);
//        }
//        
//    }];
//    
//}


#pragma mark - 获取H5方法名
+ (void)getH5MethodNameWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/common/driver/variable.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

#pragma mark - 支付宝支付
/// 获取配置文件接口
+ (void)aliPayWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/pay/alipay/tradeUrl",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

#pragma mark - 微信支付
/// 获取配置文件接口
+ (void)wxPayWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/pay/wx/tradeUrl",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

#pragma mark - 余额支付
/// 获取配置文件接口
+ (void)yuePayWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/token/pay/balance/tradeUrl",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}

#pragma mark - 强制更新
+ (void)getVersionInfoWithParameters:(NSDictionary*)parameters success:(void(^)(id data))success failure:(void(^)(NSError *error))failure {
    
    NSMutableURLRequest *request = [ConnectionBaseManager postRequestWithURLString:[NSString stringWithFormat:@"%@/api/v1/driver/version/check.yueyue",[QXDriverConfiguration apiBaseUrlString]] parameters:parameters token:YueYueTaiDriver_Tocken];
    request.timeoutInterval = TimeLimites;
    [self connectWithRequest:request success: success failure:failure];
}



@end
